var m_DialogGroup = [], m_Start = false;
  //计时器，按着队列一个一个消失
  function removeDialog() {
    var m_Time = setInterval(() => {
      let m_ElementGroup = document.getElementsByClassName("dialog");
      if (m_ElementGroup.length > 0) {
        m_DialogGroup.shift();
        m_ElementGroup[0].remove();
        Array.from(m_ElementGroup).forEach(element => {
          element.style.top = (parseInt(element.style.top) - 80) + 'px';
        })
        for (let i = 0; i < m_DialogGroup.length; i++) {
          m_DialogGroup[i] -= 80;
        }
      }
      if (m_ElementGroup.length == 0) {
        m_Start = false;
        clearInterval(m_Time);
      }
    }, 2000);
  }

  function show(msg, type, width, height) {
    m_DialogGroup[0] = -80;
    let m_Top = m_DialogGroup.slice(-1)[0] + 80;
    m_DialogGroup.push(m_Top);
    let m_Dialog = document.createElement("div");
    m_Dialog.style.height = height + "px";
    m_Dialog.style.width = width + "px";
    m_Dialog.className = "dialog";
    m_Dialog.innerText = msg;
    m_Dialog.setAttribute("type", type);
    document.getElementsByTagName("body")[0].append(m_Dialog);
    setTimeout(() => {
      m_Dialog.style.opacity = 1;
      m_Dialog.style.top = m_Top + 'px';
    }, 0);
    if (m_Start == false) {
      m_Start = true;
      removeDialog();
    }
  }

  module.exports = {
    show
  }